#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>

int MaxSize = 128;

char *line;
char *cache;

typedef struct editor
{
  char *line;
  struct editor *previousLine;
  struct editor *nextLine;
}EditorNode;

int stringSize(char *line)
{
  int size = 0;
  char *p = line;
  while(*p != '\0')
    size++;
  return size;
}

void CopyAndInsert(char *line)
{
  int lineSize = stringSize(line);
  char *newLine = (char *)malloc(sizeof(char)*(lineSize + 1));
  strcpy(newLine,line);
}

int main(int argc,char **argv)
{
  FILE *fp = fopen("MyEditor.c","r");
  char c;
  int lineIndex = 0;
  if(fp == NULL) 
    {
      exit(1);
    }

  line = (char*)malloc(MaxSize*sizeof(char));
  memset(line,0,MaxSize);

  while((c = getc(fp))  != EOF) 
    {
      //printf("%c",c); //act like a cat
      if(c == '\n') 
        {
          line[lineIndex] = '\0';
          
        }

      if(lineIndex>MaxSize)
        {
          
        }
      
      line[lineIndex++] = c;
      
    }
  
  fclose(fp);
  return 0;
}
